package com.xinqi.modules.chat.third.rongyun.controller.inner;

import com.xinqi.common.base.response.R;
import com.xinqi.common.core.utils.MessageUtils;
import com.xinqi.modules.chat.third.rongyun.service.RongyunService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 融云服务frient client
 *
 * @version V1.0
 * @Title:
 * @ClassName: com.xinqi.modules.chat.third.rongyun.client.RongyunController.java
 * @Description:
 * @Copyright 2022-2023 www.xingqiclass.com - Powered By 星奇科技
 * @author: dgyu
 * @date: 2023-03-09 15:36
 */
@RequestMapping("/inner/rongyun")
@RequiredArgsConstructor
@RestController
public class RongyunController {

    private final RongyunService rongyunService;

    /**
     * 用户注册融云
     *
     * @param userId
     * @param userName
     * @param avatar
     * @return
     */
    @GetMapping("/registUser")
    public R<String> registUser(String userId, String userName, String avatar) {
        return R.ok(MessageUtils.message("user.register.success"), rongyunService.registUser(userId, userName, avatar));
    }

    /**
     * 刷新用户信息
     *
     * @param userId
     * @param userName
     * @param avatar
     * @return
     */
    @GetMapping("/updateUser")
    public R<Boolean> updateUser(String userId, String userName, String avatar) {
        return R.ok(rongyunService.updateUser(userId, userName, avatar));
    }

    /**
     * 发送消息
     *
     * @param targetIds
     * @param json
     * @return
     */
    @GetMapping("/creatSend")
    public R<Boolean> creatSend(String[] targetIds, String json) {
        return R.ok(rongyunService.sentSystemCmdMsg(targetIds, json));
    }

    /**
     * 系统用户发送消息
     *
     * @param targetIds
     * @param json
     * @return
     */
    @GetMapping("/creatSysUserSend")
    public R<Boolean> creatSysUserSend(String[] targetIds, String json) {
        return R.ok(rongyunService.sentSystemUserCmdMsg(targetIds, json));
    }

    /**
     * 融云封禁
     *
     * @param userId
     * @param minute 封禁时长，单位为分钟，最大值为 43200 分钟。
     * @return
     */
    @GetMapping("/ban")
    public R<Boolean> ban(String userId, Integer minute) {
        return R.ok(rongyunService.ban(userId, minute));
    }

}
